//circleList用于从放圆圈对象的数组

function Clrcle(x,y,r,opacity,speed){
    this.x = x;
    this.y = y;
    this.r = r;
    this.opacity = opacity;
    this.speed = speed;
}
// 使用构造函数的方法来进行数据的给予
var circleList = [new Clrcle(-80,150,40,0.2,3),
    new Clrcle(-400,250,80,0.2,2),
    new Clrcle(-280,120,50,0.2,1)]

// var circleList = [{
//     x: -80, //所在坐标
//     y: 150,
//     r: 40, //半径大小
//     opacity: 0.2, //透明度
//     speed: 3 //移动速度
// }, {
//     x: -400, //所在坐标
//     y: 250,
//     r: 80, //半径大小
//     opacity: 0.2, //透明度
//     speed: 2 //移动速度

// }, {
//     x: -280, //所在坐标
//     y: 120,
//     r: 50, //半径大小
//     opacity: 0.2, //透明度
//     speed: 1 //移动速度

// }]


//绘制对象到画布
function drawClrcle(ctx) {
    var length = circleList.length;
    for (var i = 0; i < length; i++) {
        var circle = circleList[i];

        ctx.beginPath()
        ctx.fillStyle = "rgba(255,255,255," + circle.opacity + ")";
        ctx.arc(circle.x, circle.y, circle.r, 0, 2 * Math.PI);
        ctx.fill();

        circle.x += circle.speed;

        if (circle.x > WIDTH + circle.r) {
            circle.r = getRandom(30,100);
            circle.y = getRandom(0, HEIGHT);
            circle.x = -2 * circle.r

            circle.speed = getRandom(3,6);
            circle.opacity = getRandom(1,3)/10;
        }

    }
}